<template>
  <div class="list-container">
    <div class="list">
      <div class="item" v-for="item in itemList" :key="item.id">
        <img @click="toSongIndex(item)" :src="item.song_sheet_photo" alt />
        <div class="text">
          <span class="fs-26">{{item.song_sheet_name}}</span>
        </div>
        <div class="play-mes">
          <div class="img">
            <img :src="playBtnS" alt />
          </div>
          <span class="num fs-24">{{item.run_num}}次播放</span>
        </div>
      </div>
    </div>
  </div>
</template>

<script>
export default {
  name: "item-list",
  data() {
    return {
      title: "item-list",
      itemList: [],
      playBtnS: require("@/assets/index/playVideoS.png")
    };
  },
  props: {
    id: Number
  },
  watch: {
    id: function(val) {
      this.getSonList();
    }
  },
  methods: {
    // 获取歌单列表数据
    getSonList() {
      const url =
        this.$host1 +
        `/home/recommendSongSheetList?song_sheet_category_name=` +
        this.id;
      this.$axios
        .get(url)
        .then(res => {
          // console.log(res.data.data,'----res.data.data');
          if (res.data.code == 200) {
            this.itemList = res.data.data;
          } else {
            this.AlertWin(res.data.msg);
          }
        })
        .catch(err => {
          console.log(err, "err-----");
        });
    },
    // 跳转到歌曲列表页
    toSongIndex(item) {
      this.$router.push({
        path: "/index/song-sheet",
        query: { id: item.song_sheet_id, sheetStatus: 1 }
      });
    }
  },
  created() {
    this.getSonList();
  }
};
</script>

<!-- Add "scoped" attribute to limit CSS to this component only -->
<style lang="scss" scoped>
.list-container {
  height: 100%;
  padding-bottom: 1.2rem;
  // padding-top: 1.5rem;
  // 列表样式设置
  .list {
    display: flex;
    width: 100%;
    background-color: #fff;
    flex-wrap: wrap;
    flex-direction: row;
    justify-content: flex-start;
    padding: 0 0.2rem 0 0.23rem;
    box-sizing: border-box;
    .item {
      position: relative;
      width: 2.2rem;
      height: 3rem;
      margin-bottom: 0.37rem;
      margin-right: 0.15rem;
      img {
        width: 100%;
        height: 2.2rem;
        object-fit: cover;
        border-radius: 0.06rem;
        margin-bottom: 0.17rem;
      }
      .text {
        height: 0.8rem;
        span {
          width: 100%;
          word-break: break-all;
          text-overflow: ellipsis;
          display: -webkit-box;
          -webkit-box-orient: vertical;
          -webkit-line-clamp: 2;
          overflow: hidden;
          font-weight: bold;
          color: rgba(102, 102, 102, 1);
          text-align: center;
        }
      }
      .play-mes {
        position: absolute;
        display: flex;
        align-items: center;
        right: 0.15rem;
        top: 0.15rem;
        .img {
          width: 0.16rem;
          height: 0.19rem;
          margin-right: 0.1rem;
          img {
            width: 100%;
            height: 100%;
          }
        }
        span {
          font-size: 0.22rem;
          color: #fff;
        }
      }
    }
  }
}
</style>
